package com.battle.service.controller.web;

import com.battle.pojo.param.userMessage.*;
import com.battle.pojo.vo.teamWarCase.GetTeamWarCaseVo;
import com.battle.pojo.vo.userMessage.*;
import com.battle.service.service.in.*;
import nirvana.core.context.WebContext;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/用户消息
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/userMessage/web")
public class UserMessageWebController {

    private final UserMessageService service;

    public UserMessageWebController(UserMessageService service) {
        this.service = service;
    }


    /**
     * 批量已读消息
     *
     * @param param
     */
    @PutMapping("/editUserMessage")
    public ApiResult editUserMessage(@RequestBody @Valid EditUserMessageParam param) {
        service.editUserMessage(param);
        return ApiResult.ok();
    }

    /**
     * 获取用户消息列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getUserMessageList")
    public ApiResult<PageResult<GetUserMessageListVo>> getUserMessageList(@RequestBody GetUserMessageListParam param) {
        PageResult<GetUserMessageListVo> result = service.getUserMessageList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获得未提交的消息数量
     * @return
     */
    @GetMapping("/getUserMessageCount")
    public ApiResult<Integer> getUserMessageCount() {
        Integer vo = service.getUserMessageCount(WebContext.getCurrentUserId());
        return ApiResult.ok(vo);
    }
}

